#include <vector>
#include <iostream>

void dfs(std::vector<std::vector<int>> &pub_ver,
         std::vector<bool> &vis_ver,
         int i, int &max_ver)
{
    vis_ver[i] = true;
    max_ver++;
    int cols = pub_ver[0].size();
    for (int k = 0; k < cols; k++)
    {
        if (!vis_ver[k] && pub_ver[i][k] == 1)
        {
            dfs(pub_ver, vis_ver, k, max_ver);
        }
    }
}

int main()
{
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> pub_ver(N, std::vector<int>(N, 0));
    std::vector<bool> vis_ver(N, false);

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            std::cin >> pub_ver[i][j];
        }
    }

    int max_cnt = 0;
    for (int i = 0; i < N; i++)
    {
        // dfs()
        if (!vis_ver[i])
        {
            int cnt = 0;
            dfs(pub_ver, vis_ver, i, cnt);
            max_cnt = std::max(cnt, max_cnt);
        }
    }

    std::cout << max_cnt << std::endl;

    return 0;
}